Promise.myAll = function (prams) {
  let res, rej;
  const p = new Promise((resolve, reject) => {
    res = resolve;
    rej = reject;
  });
  let count = 0;
  const result = [];
  let i = 0;
  let fullfilledCount = 0;
  for (const pram of prams) {
    const index = i;
    i++;
    count++;
    Promise.resolve(pram).then((data) => {
      result[index] = data;
      fullfilledCount++;
      if (fullfilledCount === count) {
        res(result);
      }
    }, rej);
  }
  if (count === 0) {
    res(result);
  }
  return p;
};

Promise.myAll([1, 2, 3, 4]).then((data) => {
  console.log(data);
});
